package day13;

import java.io.*;

public class TestIn {
    public static void main(String[] args)throws Exception {
        method();
        method();
    }

    public static void method2() throws Exception {
        InputStream in = null;
        in = new BufferedInputStream(new FileInputStream("D:\\JAVA\\1.txt"));
        int b;
        while ((b = in.read()) != -1) {
            System.out.println(b);
        }
        in.close();



    }



    private static void method() throws IOException {
        InputStream in = null;
        in = new FileInputStream("D:\\JAVA\\1.txt");

        System.out.println(in.read());   //read()每次调用都会读取一个字节，如果读到尽头回返回-1
        int b;
        while( (b=in.read()) !=-1 ){
            System.out.println(b);
        }
        in.close();

    }
}
